import type { FormSchemaGetter } from '#/adapter/form';
import type { VxeGridProps } from '#/adapter/vxe-table';

// import { h } from 'vue';
import { DictEnum } from '@vben/constants';
// import { VbenIcon } from '@vben/icons';
// import { getPopupContainer } from '@vben/utils';

// import { Tag } from 'ant-design-vue';
// import { z } from '#/adapter/form';
import { getDictOptions } from '#/utils/dict';
// import { renderDict } from '#/utils/render';

export const querySchema: FormSchemaGetter = () => [
  {
    component: 'Input',
    fieldName: 'name',
    label: '问卷名称',
  },
  {
    component: 'Input',
    fieldName: 'key',
    label: '问卷KEY',
  },
  {
    component: 'Select',
    componentProps: {
      options: getDictOptions(DictEnum.SYS_NORMAL_DISABLE),
    },
    fieldName: 'status',
    label: '状态',
  },
];

export const columns: VxeGridProps['columns'] = [
  {
    field: 'name',
    title: '问卷名称',
  },
  {
    field: 'key',
    title: '问卷KEY',
    width: 160,
  },
  {
    title: '状态',
    field: 'status',
    slots: { default: 'status' },
    width: 150,
  },
  {
    field: 'remark',
    title: '备注',
    showOverflow: true,
    // visible: false,
  },
  {
    field: 'createTime',
    title: '创建时间',
    width: 180,
  },
  {
    field: 'action',
    fixed: 'right',
    slots: { default: 'action' },
    title: '操作',
    resizable: false,
    width: '240',
  },
];

export const drawerSchema: FormSchemaGetter = () => [
  {
    label: 'ID',
    fieldName: 'id',
    component: 'Input',
    dependencies: {
      show: () => false,
      triggerFields: [''],
    },
  },
  {
    component: 'Input',
    fieldName: 'name',
    label: '问卷名称',
    rules: 'required',
  },
  {
    component: 'Input',
    fieldName: 'key',
    label: '问卷KEY',
    help: '用于关联查询，请用字母+数字的格式组合定义',
    rules: 'required',
  },
  {
    component: 'RadioGroup',
    componentProps: {
      buttonStyle: 'solid',
      options: getDictOptions(DictEnum.SYS_NORMAL_DISABLE),
      optionType: 'button',
    },
    defaultValue: '0',
    fieldName: 'status',
    label: '状态',
    rules: 'selectRequired',
  },
  {
    component: 'Textarea',
    fieldName: 'remark',
    label: '备注',
  },
];
